package com.xubeizhi.controller.system;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xubeizhi.annotation.OperationLogger;
import com.xubeizhi.common.ResponseResult;
import com.xubeizhi.entity.SystemConfig;
import com.xubeizhi.service.SystemConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统配置表 前端控制器
 * @author mi
 * @create 2023/3/22 14:45
 */
@RequestMapping("/system/config")
@RestController
@Api(tags = "系统配置表")
@RequiredArgsConstructor
public class SystemConfigController {
    private final SystemConfigService systemConfigService;

    @RequestMapping(value = "/getConfig",method = RequestMethod.GET)
    @SaCheckLogin
    @ApiOperation(value = "获取系统配置",httpMethod = "GET",response = ResponseResult.class,notes = "获取系统配置")
    public ResponseResult getConfig(){
        return systemConfigService.getConfig();
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @SaCheckPermission("/system/config/update")
    @ApiOperation(value = "修改配置",httpMethod = "POST",response = ResponseResult.class,notes = "修改配置")
    @OperationLogger(value = "修改配置")
    public ResponseResult update(@RequestBody SystemConfig systemConfig){
        return systemConfigService.updateConfig(systemConfig);
    }
}
